package com.huatai.exchange.load;

import com.faneui.common.exception.BusinessException;
import com.huatai.exchange.facade.enums.FileTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DataFileLoadFactory {

    @Autowired
    private DataFileLoadService dataBaseFileLoadService;

    @Autowired
    private DataFileLoadService dataDbfFileLoadService;

    @Autowired
    private DataFileLoadService dataExcelFileLoadService;

    @Autowired
    private DataFileLoadService dataTxtFileLoadService;


    public DataFileLoadService getLoadService(String fileSuffix) throws BusinessException {
        if (FileTypeEnum.DBF.toString().equalsIgnoreCase(fileSuffix)) { // http 获取文件
            return dataDbfFileLoadService;
        } else if (FileTypeEnum.XLSX.toString().equalsIgnoreCase(fileSuffix)) {
            return dataExcelFileLoadService;
        } else if (FileTypeEnum.XLS.toString().equalsIgnoreCase(fileSuffix)) {
            return dataExcelFileLoadService;
        } else if (FileTypeEnum.TXT.toString().equalsIgnoreCase(fileSuffix)) {
            return dataTxtFileLoadService;
        } else if (FileTypeEnum.PDF.toString().equalsIgnoreCase(fileSuffix)) { // http 获取文件
            return dataBaseFileLoadService;
        } else if (FileTypeEnum.ZIP.toString().equalsIgnoreCase(fileSuffix)) { // http 获取文件
            return dataBaseFileLoadService;
        } else if (FileTypeEnum.XML.toString().equalsIgnoreCase(fileSuffix)) { // http 获取文件
            return dataBaseFileLoadService;
        } else if (FileTypeEnum.PPT.toString().equalsIgnoreCase(fileSuffix)) { // http 获取文件
            return dataBaseFileLoadService;
        } else  { // http 获取文件
            throw new BusinessException("无效文件类型");
        }
    }

}
